package com.isnotlocus.gulimail.ware.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isnotlocus.common.utils.PageUtils;
import com.isnotlocus.common.utils.Query;

import com.isnotlocus.gulimail.ware.dao.WareInfoDao;
import com.isnotlocus.gulimail.ware.entity.WareInfoEntity;
import com.isnotlocus.gulimail.ware.service.WareInfoService;


@Service("wareInfoService")
public class WareInfoServiceImpl extends ServiceImpl<WareInfoDao, WareInfoEntity> implements WareInfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<WareInfoEntity> page = this.page(
                new Query<WareInfoEntity>().getPage(params),
                new QueryWrapper<WareInfoEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils selectByBatchs(Map<String, Object> params) {
        QueryWrapper<WareInfoEntity> wrapper =new QueryWrapper<WareInfoEntity>();
       try{
        String key=params.get("key").toString();
        if(!StringUtils.isEmpty(key)&&!key.equalsIgnoreCase("")){
            wrapper.and((item)->{
               item.eq("id",key).or().like("name",key).or().like("address",key).or().like("areacode",key);
            });
        }
       }catch (Exception e ){

       }
         IPage<WareInfoEntity> page=this.page(new Query<WareInfoEntity>().getPage(params),wrapper);
        return new PageUtils(page);
    }

}